package com.idemon.springbootcache;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

@Repository
public class UserinfoDAOImpl implements UserinfoDAO {
    @Override
    @Cacheable("userinfos")
    public Userinfo getByName(String username) {
//        模拟查询耗时3000ms
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return new Userinfo(username, 18);
    }
}
